﻿{PE.DataSource id="cone" datasource="积分商品_内容页" presentId="@RequestInt_id" xslt="true"
/}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="UTF-8">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="Description" content="{PE.Field id="cone" fieldname="ProductIntro" /}" />
    <meta content="{PE.Field id="cone" fieldname="Keyword" /}" name="Keywords" />
    <title>积分商品内容页-{PE.SiteConfig.SiteName /}</title>
    <link href="{PE.SiteConfig.SkinPath/}common.css" rel="stylesheet" type="text/css" />
    <link href="{PE.SiteConfig.SkinPath/}product.css" rel="stylesheet" type="text/css" />
    <link href="{PE.SiteConfig.SkinPath/}default.css" rel="stylesheet" type="text/css" />
    <link href="{PE.SiteConfig.SkinPath/}commentary.css" rel="stylesheet" type="text/css" />
    <link href="{PE.SiteConfig.SkinPath/}ebuy.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.ApplicationPath/}JS/Common.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.ApplicationPath/}JS/jsPopup.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.SkinPath/}js/script60.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.ApplicationPath/}JS/jquery.pack.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.applicationpath/}js/jquery.cookie.min.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.ApplicationPath/}JS/jquery.timers.js"></script>

    <script language="javascript" type="text/javascript" src="{PE.SiteConfig.ApplicationPath/}JS/TabOption.js"></script>

    <script language="javascript" type="text/javascript">
        jQuery(document).ready(function() {
            ClickTab("#menu_1", 0, "on", "span");
        });
    </script>

</head>
<body>
    {PE.Label id="商城网站顶部(内容)" /}
    <div id="mainContent" class="main">
        <div id="main_right">
            <div class="showBar">

                <script type="text/javascript" src='{PE.SiteConfig.adpath/}/200810/17.js'></script>

                <div class="spacing">
                </div>
                <div class="navigation">
                    您现在的位置：积分商品内容页</div>
                <div class="spacing">
                </div>
                <div id="productContent">
                    <div class="itemContent fullwidth">
                        <div class="itemInfo">
                            <h3>
                                {PE.Field id="cone" fieldname="PresentName" /}</h3>
                            <ul id="productInfo">
                                <li>市 场 价：<span class='marketPrice'>{PE.Field id="cone" fieldname="Price_Market" /}
                                    元</span></li>
                                <li class="price">换购积分：<span class="priceStyle">{PE.Field id="cone" fieldname="NeedCredits"
                                    /}</span> </li>
                                {PE.Control.HdnUserCredits/}
                            </ul>
                            <ul>
                                <li>库 存 量：<span id="productStocks">{PE.Field id="cone" fieldname="Stocks" /}</span><div>
                                    换购次数：{PE.Field id="cone" fieldname="BuyTimes" /}</div>
                                </li>
                                <li class="buttonCol"><em class="addShopCar"><a href="#" id="buyProduct">换购</a></em><em
                                    class="addFav"><a href="CreditsProductlist.aspx" id="backToList" target="_self">返回列表</a></em></li>
                            </ul>
                        </div>
                        <div class="itemPic">
                            <div class="pic">
                                {PE.Label id="商品图片链接处理" ProductThumb="{PE.Field id="cone" fieldname="PresentThumb"
                                /}" ProductPic="{PE.Field id="cone" fieldname="PresentPic" /}"/}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="spacing">
                </div>
                <div id="menu_1" class="ShopTab">
                    <dl>
                        <dt><span><em>详细介绍</em></span> </dt>
                        <dd>
                            {PE.Field id="cone" fieldname="PresentExplain" /}</dd>
                    </dl>
                </div>
                <div class="spacing">
                </div>
                <div class="spacing">
                </div>
            </div>
        </div>
        <div id="main_left">
            {PE.Label id="积分商品列表页左侧" /}</div>
        <div class="clearbox">
        </div>
    </div>
    <!--End 栏目页内容模块-->
    {PE.Label id="商城网站底部" /}

    <script type="text/javascript">
        jQuery(document).ready(function() {
            var isLogin = false;
            CheckLogin();

        //检验登录
        function CheckLogin() {
            jQuery.ajax({ url: "{PE.SiteConfig.ajaxsitepath/}Shop/CreditsProductAjaxHandler.aspx", type: 'post', dataType: 'xml', data: { 'action': 'checkLogin' },
                success: function(data) {
                    status = jQuery("status", data).text();
                    if (status == "false") {
                        isLogin = false;
                    }
                    else {
                        isLogin = true;
                        var userName = jQuery("UserName", data).text();
                        userCredits = parseInt(jQuery("UserCredits", data).text());
                    }
                    jQuery.cookie("isLogin", isLogin, { path: cookiePath, expires: cookieExpires });
                }
            });
        };

            var cookieExpires = null; //cookie的有效期:null表示有效期为浏览进程；可填入天数和具体的有效日期
            var cookieDomain = ""; //cookie的域,默认为网站的域名
            var cookiePath = '/'; //cookie的路径,如果发生cookie错误，一般是这里的路径没设置对
            if (document.URL.indexOf('WebApplication') > 0)
                cookiePath = '/WebApplication/';

            //显示信息
            function ShowMsg(msg, obj) {
                var position = jQuery(obj).position();
                var msgBox = '<div class="msgBox">' + msg + '</div>';
                jQuery(msgBox).insertBefore(obj).css({ top: position.top + "px", left: (position.left + jQuery(obj).outerWidth()) + "px" })
            .oneTime(1000, function() {
                jQuery(this).show("fast", function() {
                    jQuery(this).hide("fast", function() {
                        jQuery(this).remove();
                    });
                });
            });
            };

            jQuery("#buyProduct").click(function() {
                if (!isLogin) {
                    ShowMsg("请先登录！", this);
                    return false;
                }

                var productId = '@RequestInt_id';
                var productName = '{PE.Field id="cone" fieldname="PresentName" /}';
                var productCredit = '{PE.Field id="cone" fieldname="NeedCredits" /}';
                var productQuantity = "1"; //parseInt(jQuery("#txtNum").val());

                var userCredits = parseInt(jQuery("#HdnUserCredits").val());
                var oTotalCredits = 0;
                if (jQuery.cookie("totalCredits") != "" && jQuery.cookie("totalCredits") != null) {
                    oTotalCredits = parseInt(jQuery.cookie("totalCredits"));
                }
                if ((oTotalCredits + parseInt(productCredit)) > userCredits) {
                    ShowMsg("您的积分不足！", this);
                    return false;
                }

                if (jQuery.cookie("creditProducts") != null) {
                    var regx = new RegExp('\\{"ProductID":' + productId + ',([\\s\\S]*?),"ProductName":"' + productName + '"\\};');
                    var creditProducts = jQuery.cookie("creditProducts");
                    if (regx.test(creditProducts)) {
                        var oldCookie = jQuery.cookie("creditProducts").match(regx)[1];
                        var oldQuantity = parseInt(oldCookie.substring(oldCookie.lastIndexOf(":") + 2, oldCookie.length - 1));
                        var newCookie = '{"ProductID":' + productId + ',"ProductCredit":"'
                    + productCredit + '","ProductQuantity":"' + (oldQuantity + 1) + '","ProductName":"' + productName + '"};';
                        var newCreditProductsCookie = creditProducts.replace(regx, newCookie);
                        jQuery.cookie("creditProducts", newCreditProductsCookie, { path: cookiePath, expires: cookieExpires });
                    }
                    else {
                        var newCreditProduct = '{"ProductID":' + productId + ',"ProductCredit":"'
                    + productCredit + '","ProductQuantity":"' + productQuantity + '","ProductName":"' + productName + '"};';
                        creditProducts += newCreditProduct;
                        jQuery.cookie("creditProducts", creditProducts, { path: cookiePath, expires: cookieExpires });
                    }
                }
                else {
                    var newCreditProduct = '{"ProductID":' + productId + ',"ProductCredit":"'
                    + productCredit + '","ProductQuantity":"' + productQuantity + '","ProductName":"' + productName + '"};';
                    jQuery.cookie("creditProducts", newCreditProduct, { path: cookiePath, expires: cookieExpires });
                }

                if (jQuery.cookie("totalCredits") != null) {
                    var oldTotalCredits = isNaN(parseInt(jQuery.cookie("totalCredits"))) ? 0 : parseInt(jQuery.cookie("totalCredits"));
                    jQuery.cookie("totalCredits", oldTotalCredits + parseInt(productCredit), { path: cookiePath, expires: cookieExpires });
                }
                else {
                    jQuery.cookie("totalCredits", parseInt(productCredit), { path: cookiePath, expires: cookieExpires });
                }

                ShowMsg("已将商品添加到购物车，请返回列表页查看。", this);

                return false;
            });

        });
    </script>

</body>
</html>
